package edu.westga.movierec.XAMPPtests.reader;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import edu.westga.movierec.model.*;
/**
 * Test methods for {@link edu.westga.movierec.model.XamppDBConnector#addMovieToDatabase(String)}.
 * 
 * @author Jean Cook, CS 6242, Fall 2009
 *
 */
public class AddMoviesToDatabaseTests {
	private XamppDBConnector theDatabase;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		this.theDatabase = new XamppDBConnector();
	}
	//movie already there
	@Test
	public void getMovieIndexShouldBe1WhenMovieIsScream(){
		this.theDatabase.addMovieToDatabase("Scream");
		assertEquals(this.theDatabase.getMovieIndex("Scream"),1);
	}
	//movie not there
	@Test
	public void getMovieIndexShouldBe6WhenMovieIsStarWars(){
		this.theDatabase.addMovieToDatabase("Star Wars");
		assertEquals(this.theDatabase.getMovieIndex("Star Wars"),8);
		for(int i=1;i<this.theDatabase.getMovieIndex("Star Wars");i++){
			assertEquals(this.theDatabase.getMovieRating(this.theDatabase.getMovieTitle(i),"Star Wars"),0);
			assertEquals(this.theDatabase.getMovieRating("Star Wars",this.theDatabase.getMovieTitle(i)),0);
		}
	}
}
